// Symbol
<template>
  <div>
    <prism language="javascript">
      let s1 = Symbol("foo");
      let s2 = Symbol("foo"); //加上参数利于区分是哪个Symbol
      console.log(s1 == s2); //s1与s2永远不相等
      console.log(typeof s1); //symbol
      console.log(s2.toString());
      //如果s不放在方括号中，该属性的键名就是字符串s，而不是s所代表的那个 Symbol 值。
      let obj = {
      [s1]: "yuanleiSymbol",
      sx: "属性值"
      };
      console.log(obj[s1]); //yuanleiSymbol
      let f1 = Symbol.for("foo"); //let f1=Symbol.for("foo");
      let f2 = Symbol.for("foo");
      console.log(f1 == f2); //true
      console.log(Symbol.keyFor(f2));
    </prism>
    <v-btn
      round
      color="success"
      @click="run"
    >
      RUN
    </v-btn>
  </div>
</template>

<script>
import Prism from "vue-prism-component";
export default {
  components: {
    Prism
  },
  methods: {
    run() {
      let s1 = Symbol("foo");
      let s2 = Symbol("foo"); //加上参数利于区分是哪个Symbol
      console.log(s1 == s2); //s1与s2永远不相等
      console.log(typeof s1); //symbol
      console.log(s2.toString());
      //如果s不放在方括号中，该属性的键名就是字符串s，而不是s所代表的那个 Symbol 值。
      let obj = {
        [s1]: "yuanleiSymbol",
        sx: "属性值"
      };
      console.log(obj[s1]); //yuanleiSymbol
      let f1 = Symbol.for("foo"); //let f1=Symbol.for("foo");
      let f2 = Symbol.for("foo");
      console.log(f1 == f2); //true
      console.log(Symbol.keyFor(f2));
    }
  }
};
</script>